package com.itqf.utils;

import com.mongodb.MongoClient;
import com.mongodb.client.MongoCollection;
import com.mongodb.client.MongoDatabase;
import org.bson.Document;

/**
 * @Description:
 * @Company: 千锋互联
 * @Author: 李丽婷
 * @Date: 2021/1/6
 * @Time: 下午4:51
 */
public class MongoUtils {

    public static  MongoCollection<Document>  getCollection(){
        //1.构建mongodb的客户端
        MongoClient mongoClient = new MongoClient("10.9.48.183"
                ,27017);
        //2.创建数据库
        MongoDatabase mongoDatabase = mongoClient.getDatabase("shop");
        //3.创建表
        MongoCollection<Document> mongoCollection =  mongoDatabase.getCollection("product");

        return  mongoCollection;
    }

}
